<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 键盘事件 1.keyup 2.keydown
        // document.onkeyup = function () {
        //     console.log("键盘抬起");
        // }
        // document.onkeydown = function () {
        //     console.log("键盘按下")
        // }

        // 区分每个按键  keyCode

        // document.onkeyup = function (e) {
        //     var e = e || window.event;
        //     // console.log("键盘抬起",e.keyCode);
        //     if(e.keyCode===13){
        //         console.log("你按了enter按键");
        //     }
        // }

        // 组合按键
        document.onkeydown = function (e) {
            var e = e || window.event;
            //    console.log( e.altKey,e.shiftKey, e.ctrlKey  )
            if (e.altKey && e.keyCode === 13) {
                console.log("按了alt+enter按键");
            }

        }

    </script>
</body>

</html>